]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Only add hot corner for primary and "top left" monitors
authorAlexander Larsson <alexl@redhat.com>
Fri, 18 Mar 2011 13:21:17 +0000 (14:21 +0100)
committerAlexander Larsson <alexl@redhat.com>
Mon, 21 Mar 2011 09:32:30 +0000 (10:32 +0100)
To avoid having hot corners that accidentally trigger when e.g. trying
to hit the panel on the primary monitor we add hot corners only to
monitors that are "naturally" top left (top right for RTL).

For instance, we'd like a hot corner here:

corner -> +-------------
          |            |
+---------+            |
|=========|            |
|         |            |
|         |            |
|         |            |
+---------+------------+

But not here:

          unexpected hot corner
          ↓
+---------+-------+
|=========|       |
|         |       |
|         +-------+
+---------+

https://bugzilla.gnome.org/show_bug.cgi?id=645116

js/ui/main.js

index b5589978d75800a16b84ec276c483f6b83a0e4ca..47dadef3b551142f3b5fc3b74705a30a2e6fca89 100644 (file)
@@ -480,28 +480,67 @@ function _getAndClearErrorStack() {
 
 function _relayout() {
     let monitors = global.get_monitors();
-    if (monitors.length != hotCorners.length) {
-        // destroy old corners
-        for (let i = 0; i < hotCorners.length; i++)
-            hotCorners[i].destroy();
-        hotCorners = [];
-        for (let i = 0; i < monitors.length; i++)
-            hotCorners[i] = new Panel.HotCorner();
-    }
+    // destroy old corners
+    for (let i = 0; i < hotCorners.length; i++)
+        hotCorners[i].destroy();
+    hotCorners = [];
 
 
     let primary = global.get_primary_monitor();
     for (let i = 0; i < monitors.length; i++) {
         let monitor = monitors[i];
-        let corner = hotCorners[i];
         let isPrimary = (monitor.x == primary.x &&
                          monitor.y == primary.y &&
                          monitor.width == primary.width &&
                          monitor.height == primary.height);
+
+        let cornerX = monitor.x;
+        let cornerY = monitor.y;
         if (St.Widget.get_default_direction() == St.TextDirection.RTL)
-            corner.actor.set_position(monitor.x + monitor.width, monitor.y);
+            cornerX += monitor.width;
+
+
+        let haveTopLeftCorner = true;
+
+        /* Check if we have a top left (right for RTL) corner.
+         * I.e. if there is no monitor directly above or to the left(right) */
+        let besideX;
+        if (St.Widget.get_default_direction() == St.TextDirection.RTL)
+            besideX = monitor.x + 1;
         else
-            corner.actor.set_position(monitor.x, monitor.y);
+            besideX = cornerX - 1;
+        let besideY = cornerY;
+        let aboveX = cornerX;
+        let aboveY = cornerY - 1;
+
+        for (let j = 0; j < monitors.length; j++) {
+            if (i == j)
+                continue;
+            let otherMonitor = monitors[j];
+            if (besideX >= otherMonitor.x &&
+                besideX < otherMonitor.x + otherMonitor.width &&
+                besideY >= otherMonitor.y &&
+                besideY < otherMonitor.y + otherMonitor.height) {
+                haveTopLeftCorner = false;
+                break;
+            }
+            if (aboveX >= otherMonitor.x &&
+                aboveX < otherMonitor.x + otherMonitor.width &&
+                aboveY >= otherMonitor.y &&
+                aboveY < otherMonitor.y + otherMonitor.height) {
+                haveTopLeftCorner = false;
+                break;
+            }
+        }
+
+        /* We only want hot corners where there is a natural top-left
+         * corner, and on the primary monitor */
+        if (!isPrimary && !haveTopLeftCorner)
+            continue;
+
+        let corner = new Panel.HotCorner();
+        hotCorners.push(corner);
+        corner.actor.set_position(cornerX, cornerY);
         if (isPrimary)
             panel.setHotCorner(corner);
     }